/**
 * 
 */
package com.coders.vimek.Javatutorials;

/**
 * @author vimek
 *
 */

class Car {
		
			void carMethod()
				{
				System.out.println("This is CarMethod()");
				}
		}

class Ford extends Car
	{
		void fordMethod () 
			{
			System.out.println("This is FordMethod()");
			
			}
	}
public class JavaObjectTypecastingExample extends Car
	{

	/**
	 * @param args
	 */
	public void brk(Car obj) 
	{
		obj.carMethod();
		if (obj instanceof Ford)
		{
		((Ford)obj).fordMethod ();
	
		}
		

		if(obj instanceof JavaObjectTypecastingExample)
		{
			System.out.println("ob  is  an object of JavaObjectTypecastingExample");
			
			
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Car obCar=new Car();
		Ford obFord=new Ford();
		JavaAbstractDerivedClassExample obj= new JavaAbstractDerivedClassExample();
		JavaObjectTypecastingExample ob= new JavaObjectTypecastingExample();
		 ob.brk(obFord);
		if(((obj) instanceof JavaAbstractDerivedClassExample))
		{
			System.out.println("obj  is  an object of JavaObjectTypecastingExample");
			
		}
		
		if(((ob) instanceof JavaObjectTypecastingExample))
		{
			System.out.println("ob  is  an object of JavaObjectTypecastingExample");
			}
			
		}
		
		
}
